<?php
session_start();
include 'connect.php';

if(isset($_POST['link_data'])) {  
    $property_id = $_POST['link_data'];

    $result = mysqli_query($conn, "SELECT property_id FROM featuredlists WHERE property_id = ".$property_id) or die(mysqli_error($conn));

    if(mysqli_num_rows($result) > 0){

        $featuredid = mysqli_fetch_assoc($result);

                mysqli_query($conn, "DELETE FROM featuredlists WHERE property_id  = ".$property_id, MYSQLI_STORE_RESULT) or die(mysqli_error($conn)); // If product has already added to wishlist then remove from Database

                echo 0; //returns 0 as FALSE
                  
    }
    else {
        mysqli_query($conn, "INSERT INTO featuredlists SET property_id = ".$property_id, MYSQLI_STORE_RESULT) or die(mysqli_error($conn)); // If product has not in wishlist then add to Database

        echo 1;  //returns 1 as TRUE
    }
}
?>

